## PHP镜像 别名php 需要安装php扩展和composer
FROM php:8.0-fpm-alpine AS php


# PHP默认配置文件
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php_pro.ini" && mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

# 安装系统依赖
RUN apt-get update && apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    zip \
    unzip \
    libzip-dev \
    libmcrypt-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev

RUN apt-get install -y procps vim  # ps


# install extension hhxsv5/laravel-s 需要pcntl
RUN docker-php-ext-install zip mbstring mysqli pdo_mysql pcntl

# 安装 Swoole 扩展
RUN pecl install swoole-5.0.3 \
    && docker-php-ext-enable swoole

#安装 inotify 扩展 修改文件自动热重启
RUN pecl install inotify && docker-php-ext-enable inotify

# 从镜像安装compser
COPY --from=composer:2.6.2 /usr/bin/composer /usr/bin/composer

# 设置工作目录
WORKDIR /www

ENV COMPOSER_ALLOW_SUPERUSER=1


# 安装依赖 在容器内安装依赖
# 复制项目文件
#COPY . .
# RUN composer install --no-interaction --prefer-dist --optimize-autoloader
